<template>
   <p>{{msg}}</p>
    <input /><br /><br />
    <input v-focus /><br /><br />
    <input/>
</template>

<script>
import { reactive, toRefs } from 'vue'

export default {
    setup () {
        const state = reactive({
            msg: '页面加载后，第二个input元素自动获取焦点：'
        })
    
        return {
            ...toRefs(state)
        }
    }
}
</script>

<style scoped>
input:focus{ 
  background-color:black;
  color:white;
}
</style>